#include <iostream>
#include <string>
#include <unordered_map>
#include <gtest/gtest.h>

class HashTestEnv : public testing::Test
{
public:
    static void SetUpTestCase() 
    {
        std::cout << "第一个用例执行前被调用，进行总体环境配置\n";
    }
    static void TearDownTestCase() 
    {
        std::cout << "最后一个用例执行后被调用，进行总体环境清理\n";
    }
    virtual void SetUp() override
    {
        _myMap.insert(std::make_pair("hello", "你好"));
        _myMap.insert(std::make_pair("world", "世界"));
    }
    virtual void TearDown() override
    {
        _myMap.clear();
    }
public:
    std::unordered_map<std::string, std::string> _myMap;
};

TEST_F(HashTestEnv, insert_test)
{
    _myMap.insert(std::make_pair("wangshu", "帅哥"));
    ASSERT_EQ(_myMap.size(), 3);
}

TEST_F(HashTestEnv, erase_test)
{
    EXPECT_EQ(_myMap.size(), 3);
    _myMap.erase("hello");
    ASSERT_EQ(_myMap.size(), 2);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
    return 0;
}